<?
if(!defined('L_ADMOD')) {echo "<meta http-equiv='refresh' content='0; url=/?nma=error&act=403'>";exit;}
include("./inc/bloced.php");

if ($action=="newr")
{
	print '<br><br><center><b>'._WAITMESSAGE_.'</b></center>';
	if (isset($new_name) && isset($new_nom) && $new_name!='' && $new_nom!='' && $new_prod>0)
	{
		$query=mysql_query("INSERT INTO ".$wcpref.$op."_razd VALUES(NULL, '".$new_prod."', '".$new_name."', '".$new_nom."')");
		$c=0;
	}else
	{
		print '<br><br><center><b><font color="#FF0000">'._ERROR_.'</font></b>: '._EMPTY_.'</center>';
		$c=1;
	}
	echo "<meta http-equiv='refresh' content='".$c."; url=/admin.php?op=".$op."&flag=viewprod&lid=".$new_prod."'>";
}elseif($action=="newpr")
{
	print '<br><br><center><b>'._WAITMESSAGE_.'</b></center>';
	if (isset($new_product) && $new_product!='')
	{
		$query=mysql_query("INSERT INTO ".$wcpref.$op."_product VALUES(NULL, '".$new_product."')");
		$c=0;
	}else
	{
		print '<br><br><center><b><font color="#FF0000">'._ERROR_.'</font></b>: '._EMPTY_.'</center>';
		$c=1;
	}
	echo "<meta http-equiv='refresh' content='".$c."; url=/admin.php?op=".$op."'>";
}elseif($action=="newp")
{
	print '<br><br><center><b>'._WAITMESSAGE_.'</b></center>';
	if($new_razd>0 && $new_name!='' && $new_text!='' && $new_nom!='')
	{
		$query=mysql_query("INSERT INTO ".$wcpref.$op." VALUES(NULL, '".$new_razd."', '".$new_name."', '".$new_text."', '".$new_nom."')");
		$c=0;
	}else
	{
		print '<br><br><center><b><font color="#FF0000">'._ERROR_.'</font></b>: '._EMPTY_.'</center>';
		$c=1;
	}
	echo "<meta http-equiv='refresh' content='".$c."; url=/admin.php?op=".$op."'>";
}elseif($action=="edpr")
{
	print '<br><br><center><b>'._WAITMESSAGE_.'</b></center>';
	if (isset($new_product) && $new_product!='')
	{
		$query=mysql_query("UPDATE ".$wcpref.$op."_product SET
			mod_product='".$new_product."' 
		WHERE mod_id_prod='".$lid."'");
		$c=0;
	}else
	{
		print '<br><br><center><b><font color="#FF0000">'._ERROR_.'</font></b>: '._EMPTY_.'</center>';
		$c=1;
	}
	echo "<meta http-equiv='refresh' content='".$c."; url=/admin.php?op=".$op."'>";
}elseif($action=="delprod")
{
	print '<br><br><center><b>'._WAITMESSAGE_.'</b></center>';
	$query=mysql_query("SELECT * FROM ".$wcpref.$op."_razd WHERE mod_prod_id='".$lid."'");
	while($result=mysql_fetch_array($query))
	{
		extract($result);
		mysql_query("DELETE FROM ".$wcpref.$op." WHERE mod_razd_id = '".$mod_id."'");
	}
	mysql_query("DELETE FROM ".$wcpref.$op."_razd WHERE mod_prod_id = '".$lid."'");
	
	mysql_query("DELETE FROM ".$wcpref.$op."_product WHERE mod_id_prod='".$lid."'");
	echo "<meta http-equiv='refresh' content='".$c."; url=/admin.php?op=".$op."'>";
}elseif($action=="edr")
{
	print '<br><br><center><b>'._WAITMESSAGE_.'</b></center>';
	if (isset($new_name) && isset($new_nom) && $new_name!='' && $new_nom!='' && $new_prod>0)
	{
		$query=mysql_query("UPDATE ".$wcpref.$op."_razd SET
			mod_prod_id='".$new_prod."', 
			mod_razdel='".$new_name."', 
			mod_nomer='".$new_nom."' 
		WHERE mod_id='".$lid."'");
		$c=0;
	}else
	{
		print '<br><br><center><b><font color="#FF0000">'._ERROR_.'</font></b>: '._EMPTY_.'</center>';
		$c=1;
	}
	echo "<meta http-equiv='refresh' content='".$c."; url=/admin.php?op=".$op."&flag=viewprod&lid=".$new_prod."'>";
}elseif($action=="delrazd")
{
	print '<br><br><center><b>'._WAITMESSAGE_.'</b></center>';
	mysql_query("DELETE FROM ".$wcpref.$op." WHERE mod_razd_id = '".$lid."'");
	
	mysql_query("DELETE FROM ".$wcpref.$op."_razd WHERE mod_id='".$lid."'");
	echo "<meta http-equiv='refresh' content='".$c."; url=/admin.php?op=".$op."'>";
}elseif($action=="edp")
{
	print '<br><br><center><b>'._WAITMESSAGE_.'</b></center>';
	if($new_razd>0 && $new_name!='' && $new_text!='' && $new_nom!='')
	{
		$query=mysql_query("UPDATE ".$wcpref.$op." SET
			mod_razd_id='".$new_razd."', 
			mod_name='".$new_name."', 
			mod_opis='".$new_text."', 
			mod_nom='".$new_nom."' 
		WHERE mod_id_p='".$lid."'");
		$c=0;
	}else
	{
		print '<br><br><center><b><font color="#FF0000">'._ERROR_.'</font></b>: '._EMPTY_.'</center>';
		$c=1;
	}
	echo "<meta http-equiv='refresh' content='".$c."; url=/admin.php?op=".$op."'>";
}elseif($action=="delpage")
{
	print '<br><br><center><b>'._WAITMESSAGE_.'</b></center>';
	mysql_query("DELETE FROM ".$wcpref.$op." WHERE mod_id_p = '".$lid."'");
	echo "<meta http-equiv='refresh' content='".$c."; url=/admin.php?op=".$op."'>";
}
?>
